Program tracers provide an ability to track an execution sequence of a program being run on a microprocessor, a digital signal processor, a finite state machine or other processor device (generically called “processor” herein). An execution sequence is typically tracked by maintaining a log of program count values (i.e., a program trace) from a program counter (PC) (e.g., addresses or representations of addresses corresponding to program instructions that are executed). The log may be machine-interpreted into a text format, graphical format or other human-readable format for the purpose of debugging a program or otherwise analyzing its execution. Program traces provide a dynamic view into the execution sequence of a program. Such a view may be useful in efforts to improve the efficiency or speed of the program, a compiler, to study program logic, or to study the efficiency or operation of a compiler which compiles a program for the processor devices.
Because program count values may include sixteen bits or even a thirty-two bits of address data for each program instruction, and because a new instruction is typically available every clock cycle of the processor device, to trace a program by simply outputting unadulterated program count values would be burdensome and would require a great deal of physical resources. For example, a large number of dedicated pins (with related circuitry) may be necessary if every PC value is to be output from an integrated circuit on which the tracer is implemented. Further demands may result because, in addition to program counter outputs, a program tracer may multiplex program count values with other data values (e.g., data register values that provide insight into the execution sequence). In addition to physical resource demands, output of large amounts of data results in excessive power demands to generate the signals necessary to transfer the data.
Accordingly, to achieve program tracer capabilities using a reasonable amount of physical resources, program count values may be serialized (i.e., thirty-two-bit program count values are buffered and output in consecutive eight-bit segments) and compression schemes may be implemented. For example, in such schemes, because the most common program flow event is a sequential execution of instructions (i.e., the program count value increments by one to the next line of program “code” with each successive instruction), the program tracer outputs a value indicating that a single increment in the program count value has occurred, rather than outputting the entire program count value. Additionally, in the event of a discontinuity the program tracer outputs of a displacement value; that is, rather than a full program count value after the execution of the discontinuity, the program tracer provides an indication of the signed difference between the program counter value before the execution of the discontinuity (also referred to as the discontinuity source program counter value) and the program counter value after the execution of the discontinuity (also referred to as the discontinuity destination program counter value). The term “discontinuity” is defined herein as an execution of instructions, in an program, having non-sequential-program count values; for example, a discontinuity may be caused by execution of a jump, a call, or a branch.
Although such program tracer capabilities have provided a reduction in the data necessary to track the execution of a program, conventional compression schemes have resulted in losses of data and therefore incomplete program traces. A loss of data may occur because the amount of data output by the program tracer is excessive. For example, an internal buffer such as the serialization buffer may be caused to overflow due to the amount of data. Accordingly, a compromise must be made between the resources designated to tracking and an acceptable level of loss of data.
What is needed is a program tracer having an improved compression scheme, to provide fewer instances of data loss. Additionally, what is needed is a program tracer having reduced physical resource demands and reduced power demands.